/*
 RLRecyclingLog.h
 Date Created: February 18, 2010
 
 Author: Karol Krizka <kkrizka@gmail.com>
 
 Copyright (C) 2010 Green-Power
 
 URL: http://code.google.com/p/green-power
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 $Id$
 */

#import <CoreData/CoreData.h>

#import "RLRecyclingRun.h"

@class PMProfile;

/**
 * The model desciribing a recycling log. A recycling log is just a collection
 * of runs.
 */
@interface RLRecyclingLog :  NSManagedObject  
{
}

@property (nonatomic, retain) NSSet* runs;
@property (nonatomic, retain) PMProfile * owner;

/**
 * Creates a new run with the current date and adds it to the run.
 *
 * \return Reference to a new recycling run.
 */
- (RLRecyclingRun *)createRun;

/**
 * Turns the |runs| set into an ordered (by date/time) array. When using 
 * ascending, then the array has the earliest run at index 0. Otherwise the
 * latest run is at index 0.
 *
 * \param ascending Order method
 *
 * \return Ordered array of all runs
 */
- (NSArray *)runsOrderedByDate:(BOOL)ascending;

/**
 * Calculates the total money earned during the last month. Last month is
 * defined as the previous month ranging from days 1 to 31, inclusive.
 *
 * \return The total number of cents earned last month.
 */
- (NSUInteger)lastMonthTotal;

/**
 * Calculates the total money earned during the current month. The current month
 * is defined as all days from day 1 to the current day, inclusive.
 * 
 * \return The total number of cents earned this month
 */
- (NSUInteger)thisMonthTotal;

/**
 * Calculates the total money earned during all runs in this recycling log.
 *
 * \return The total number of cents earned.
 */
- (NSUInteger)overallTotal;

/**
 * Calculates the total money earned in a specified time period. The time 
 * portion is not inclusive. That is, February 10, 2010 10:00:00 to February 10,
 * 2010 10:30:00 will include an entry with date February 10, 2010 10:00:01, but
 * not an entry with date February 10, 2010 10:00:00.
 *
 * \param startDate The lower bounds on the range
 * \param endDate The upper bound on the range
 *
 * \return The total number of cents earned in the specified range
 */
- (NSUInteger)totalForPeriodStartingAt:(NSDate *)startDate
                              endingAt:(NSDate*)endDate;

@end


@interface RLRecyclingLog (CoreDataGeneratedAccessors)
- (void)addRunsObject:(NSManagedObject *)value;
- (void)removeRunsObject:(NSManagedObject *)value;
- (void)addRuns:(NSSet *)value;
- (void)removeRuns:(NSSet *)value;

@end

